package com.xbfinance.portal.web;

import com.xbfinance.portal.pojo.po.P2pAccountRecharge;
import com.xbfinance.portal.pojo.po.P2pUser;
import com.xbfinance.portal.service.PortalRechargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
public class PortalRechargeController {
    @Autowired
    private PortalRechargeService portalRechargeService;

    //充值审核需求提交
    //请求参数 rid userid money type rechargetype addip
    //返回参数 Map<"flag",boolean>
    @RequestMapping(value="/admin/saveRecharge",method= RequestMethod.POST)
    //@ResponseBody
    public String saveRecharge(P2pAccountRecharge p, HttpSession session){
        P2pUser user = (P2pUser) session.getAttribute("user");
        p.setUserid(user.getUserid());
        Map<String,Boolean> map = new HashMap<>();
        Boolean b = false;
        int i = portalRechargeService.saveRecharge(p);
        if(i!=0){
            b=true;
        }
        //map.put("flag",b);
        if(b==true){
            return "/rechargeRequestSuccess";
        }
        return "/rechargeRequestFail";
    }
}
